home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Xconq 7.0d37 / source / kernel / cmdline.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-12  |  18.1 KB  |  651 lines  |  [TEXT/KAHL]

  1. /* Command line parsing for Xconq.
  2.    Copyright (C) 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995
  3.    Stanley T. Shebs.
  4.  
  5. Xconq is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.  See the file COPYING.  */
  9.  
  10. /* Command lines get parsed in several stages, since for instance
  11.    the choice of game module will decide which variants are available. */
  12.  
  13. /* Command-line-interpreting programs always have a console. */
  14.  
  15. #ifndef USE_CONSOLE
  16. #define USE_CONSOLE
  17. #endif
  18.  
  19. #include "conq.h"
  20. #include "cmdline.h"
  21.  
  22. int popup_dialog;  /* probably to be moved elsewhere.  Massimo */
  23.  
  24. extern int checkpointinterval;
  25. extern int allbedesigners;
  26.  
  27. static void parse_world_option PROTO ((char *str));
  28. static void parse_realtime_option PROTO ((char *subopt, char *arg));
  29. static void parse_variant PROTO ((char *str));
  30.  
  31. static void add_a_raw_player_spec PROTO ((char *specstr));
  32.  
  33. /* The startup-settable options. */
  34.  
  35. static int option_alltimeout;
  36. static int option_totalgametime;
  37. static int option_perturntime;
  38. static int option_persidetime;
  39. static int option_add_default_player;
  40. static int option_automate_default_player;
  41. static int option_warnings;
  42.  
  43. static char *default_ai_type = ",mplayer";
  44.  
  45. /* This is a command-line parser that may be used in implementations that
  46.    get a command line from somewhere. */
  47.  
  48. /* This says whether the command line arguments actually chose a
  49.    specific game to play (as opposed to setting random flags). */
  50.  
  51. int gamechosen = FALSE;
  52.  
  53. /* The list of asked-for players. */
  54.  
  55. struct raw_spec {
  56.   char *spec;
  57.   struct raw_spec *next;
  58. } *raw_player_specs, *last_raw_player_spec;
  59.  
  60. static char *raw_default_player_spec;
  61.  
  62. /* The list of modules to loaded in addition to the main one. */
  63.  
  64. struct module_spec {
  65.   Module *module;
  66.   struct module_spec *next;
  67. } *extra_modules, *last_extra_module;
  68.  
  69. /* The list of accumulated variant choices. */
  70.  
  71. Obj *variant_settings;
  72.  
  73. char *programname = "";
  74.  
  75. int helpwanted = FALSE;
  76.  
  77. int haderror = FALSE;
  78.  
  79. /* Set the most basic of defaults on the dynamically-settable options. */
  80.  
  81. /* (need flags to indicate which options were actually used, so variant
  82.    handling can warn about improper use) */
  83.  
  84. void
  85. init_options()
  86. {
  87.     allbedesigners = FALSE;
  88.     option_alltimeout = 0;
  89.     option_totalgametime = 0;
  90.     option_add_default_player = TRUE;
  91.     option_automate_default_player = FALSE;
  92.     variant_settings = lispnil;
  93. }
  94.  
  95. /* This macro just checks that a required next argument is actually there. */
  96.  
  97. #define REQUIRE_ONE_ARG  \
  98.   if (i + 1 >= argc) {  \
  99.     fprintf(stderr, "Error: `%s' requires an argument\n", argv[i]);  \
  100.     exit(1);  \
  101.   }  \
  102.   numused = 2;
  103.  
  104. /* Each of these causes argument parsing to skip over the option if it's
  105.    not the right time to look at it. */
  106.  
  107. #define GENERAL_OPTION if (spec != general_options) continue;
  108. #define VARIANT_OPTION if (spec != variant_options) continue;
  109. #define PLAYER_OPTION  if (spec != player_options)  continue;
  110.  
  111. /* Generic command line parsing.  This is used by several different programs,
  112.    so it just collects info, doesn't process it much.  This is called
  113.    several times, because the validity of some args depends on which
  114.    game modules are loaded and which players are to be in the game,
  115.    and interfaces may need to do some of their own processing in between. */
  116.  
  117. void
  118. parse_command_line(argc, argv, spec)
  119. int argc, spec;
  120. char *argv[];
  121. {
  122.     char *arg, *aispec, tmpspec[100];
  123.     int i, n, numused;
  124.  
  125.     programname = argv[0];
  126.  
  127.     if (spec == general_options) init_options();
  128.  
  129.     for (i = 1; i < argc; ++i) {
  130.     if (argv[i] == NULL || (argv[i])[0] == '\0') {
  131.         /* Already munched, nothing to do. */
  132.     } else if ((argv[i])[0] == '-') {
  133.         arg = argv[i];
  134.         Dprintf("%s\n", arg);
  135.         numused = 1;
  136.         if (strcmp(arg, "-A") == 0) {
  137.         PLAYER_OPTION;
  138.         option_automate_default_player = TRUE;
  139.         } else if (strcmp(arg, "-ai") == 0) {
  140.         REQUIRE_ONE_ARG;
  141.         fprintf(stderr, "  %s not implemented yet, sorry\n", arg);
  142.         haderror = TRUE;
  143.         } else if (strcmp(arg, "-design") == 0) {
  144.         GENERAL_OPTION;
  145.         allbedesigners = TRUE;
  146.         } else if (strcmp(arg, "-c") == 0) {
  147.         REQUIRE_ONE_ARG;
  148.         GENERAL_OPTION;
  149.         checkpointinterval = atoi(argv[i+1]);
  150.         } else if (strcmp(arg, "-x") == 0) {
  151.         GENERAL_OPTION;
  152.         popup_dialog = TRUE;
  153. #ifdef DEBUGGING
  154.         } else if (strncmp(arg, "-D", 2) == 0) {
  155.         GENERAL_OPTION;
  156.         Debug = TRUE;
  157.         if (strchr(arg+2, '-'))
  158.           Debug = FALSE;
  159.         if (strchr(arg+2, 'M'))
  160.           DebugM = TRUE;
  161.         if (strchr(arg+2, 'G'))
  162.           DebugG = TRUE;
  163. #endif /* DEBUGGING */
  164.         } else if (strncmp(arg, "-e", 2) == 0) {
  165.         REQUIRE_ONE_ARG;
  166.         PLAYER_OPTION;
  167.         n = atoi(argv[i+1]);
  168.         /* A comma indicates that the name of a particular desired
  169.            AI type follows. */
  170.         if (strlen(arg) > 2) {
  171.             aispec = arg + 2;
  172.             if (*aispec != ',') {
  173.             sprintf(tmpspec, ",mplayer%s", aispec);
  174.             aispec = tmpspec;
  175.             }
  176.         } else {
  177.             aispec = default_ai_type;
  178.         }
  179.         while (n-- > 0)
  180.           add_a_raw_player_spec(aispec);
  181.         } else if (strcmp(arg, "-f") == 0) {
  182.         REQUIRE_ONE_ARG;
  183.         GENERAL_OPTION;
  184.         add_a_module(NULL, argv[i+1]); 
  185.         } else if (strcmp(arg, "-g") == 0) {
  186.         REQUIRE_ONE_ARG;
  187.         GENERAL_OPTION;
  188.         add_a_module(copy_string(argv[i+1]), NULL);
  189.         } else if (strcmp(arg, "-h") == 0) {
  190.         REQUIRE_ONE_ARG;
  191.         PLAYER_OPTION;
  192.         fprintf(stderr, "  %s not implemented yet, sorry\n", arg);
  193.         haderror = TRUE;
  194.         } else if (strcmp(arg, "-help") == 0) {
  195.         GENERAL_OPTION;
  196.         helpwanted = TRUE;
  197.         /* Will display help info later. */
  198.         } else if (strcmp(arg, "-join") == 0) {
  199.         REQUIRE_ONE_ARG;
  200.         GENERAL_OPTION;
  201.         fprintf(stderr, "  %s not implemented yet, sorry\n", arg);
  202.         haderror = TRUE;
  203.         } else if (strncmp(arg, "-L", 2) == 0) {
  204.         GENERAL_OPTION;
  205.         /* (should be adding to a search list) */
  206.         xconqlib = copy_string(arg + 2);
  207.         } else if (strcmp(arg, "-M") == 0) {
  208.         REQUIRE_ONE_ARG;
  209.         VARIANT_OPTION;
  210.         parse_world_option(argv[i+1]);
  211.         } else if (strcmp(arg, "-mail") == 0) {
  212.         GENERAL_OPTION;
  213.         fprintf(stderr, "  %s not implemented yet, sorry\n", arg);
  214.         haderror = TRUE;
  215.         } else if (strcmp(arg, "-n") == 0) {
  216.         PLAYER_OPTION;
  217.         option_add_default_player = FALSE;
  218. #ifdef DEBUGGING
  219.         } else if (strcmp(arg, "-R") == 0) {
  220.         REQUIRE_ONE_ARG;
  221.         GENERAL_OPTION;
  222.         init_xrandom(atoi(argv[i+1]));
  223. #endif
  224.         } else if (strncmp(arg, "-t", 2) == 0) {
  225.         REQUIRE_ONE_ARG;
  226.         VARIANT_OPTION;
  227.         parse_realtime_option(arg+2, argv[i+1]);
  228.         } else if (strncmp(arg, "-v", 2) == 0) {
  229.         VARIANT_OPTION;
  230.         parse_variant(arg+2);
  231.         } else if (strcmp(arg, "-w") == 0) {
  232.         GENERAL_OPTION;
  233.         option_warnings = FALSE;
  234.         } else if (strcmp(arg, "-wait") == 0) {
  235.         REQUIRE_ONE_ARG;
  236.         PLAYER_OPTION;
  237.         fprintf(stderr, "  %s not implemented yet, sorry\n", arg);
  238.         haderror = TRUE;
  239.         } else if (strcmp(arg, "--help") == 0) {
  240.         GENERAL_OPTION;
  241.         } else if (strcmp(arg, "--version") == 0) {
  242.         GENERAL_OPTION;
  243.         } else {
  244.         numused = 0;
  245.         /* Anything unrecognized during the last parse is an error. */
  246.         if (spec >= leftover_options) {
  247.             fprintf(stderr, "Unrecognized option `%s'\n", arg);
  248.             haderror = TRUE;
  249.         }
  250.         }
  251.         if (numused >= 1)
  252.           argv[i] = "";
  253.         if (numused >= 2)
  254.           argv[i+1] = "";
  255.         if (numused >= 1)
  256.           i += (numused - 1);
  257.     } else {
  258.         if (spec == player_options) {
  259.         if (*(argv[i]) == '+' || *(argv[i]) == '@') {
  260.             raw_default_player_spec = argv[i];
  261.         } else {
  262.             add_a_raw_player_spec(argv[i]);
  263.         }
  264.         argv[i] = NULL;
  265.         }
  266.     }
  267.     }
  268.     if (haderror || helpwanted) {
  269.     if (helpwanted && mainmodule != NULL) {
  270.         load_all_modules();
  271.         /* (should display other random info about the game here) */
  272.     }
  273.     general_usage_info();
  274.     exit(haderror);
  275.     }
  276. }
  277.  
  278. /* Given a module name and/or filename, add it to the list of modules
  279.    to load. */
  280.  
  281. void
  282. add_a_module(name, filename)
  283. char *name, *filename;
  284. {
  285.     Module *module;
  286.  
  287.     module = get_game_module(name);
  288.     if (module == NULL)
  289.       exit(1);  /* bad error if happens */
  290.     if (filename)
  291.       module->filename = copy_string(filename);
  292.     if (mainmodule == NULL) {
  293.     mainmodule = module;
  294.     } else {
  295.     struct module_spec *extra = (struct module_spec *) xmalloc(sizeof(struct module_spec));
  296.  
  297.     extra->module = module;
  298.     if (extra_modules == NULL)
  299.       extra_modules = extra;
  300.     else
  301.       last_extra_module->next = extra;
  302.     last_extra_module = extra;
  303.     }
  304.     gamechosen = TRUE;
  305. }
  306.  
  307. static void
  308. add_a_raw_player_spec(specstr)
  309. char *specstr;
  310. {
  311.     struct raw_spec *spec =
  312.     (struct raw_spec *) xmalloc (sizeof(struct raw_spec));
  313.  
  314.     spec->spec = copy_string(specstr);
  315.     if (raw_player_specs == NULL)
  316.       raw_player_specs = spec;
  317.     else
  318.       last_raw_player_spec->next = spec;
  319.     last_raw_player_spec = spec;
  320. }
  321.  
  322. /* This routine prints out help info about all the possible arguments. */
  323.  
  324. void
  325. general_usage_info()
  326. {
  327.     printf("Usage:\n\t%s [ -options ... ]\n\n", programname);
  328.     printf("General options:\n\n");
  329.     printf("    -design\t\tmake every player a designer\n");
  330.     printf("    -c n\t\tcheckpoint every <n> turns\n");
  331.     printf("    -f filename\t\trun <filename> as a game\n");
  332.     printf("    -g gamename\t\tfind <gamename> in library and run it\n");
  333.     printf("    -help\t\tdisplay this help info\n");
  334.     printf("    -join <game@host>\tconnect to the given game\n");
  335.     printf("    -Lpathname\t\tset <pathname> to be library location\n");
  336.     printf("    -mail\t\tset up game as play-by-mail\n");
  337.     printf("    -t mins\t\tlimit each player to <mins> of play time total\n");
  338.     printf("    -tside mins\t\tlimit each player to <mins> of time each turn\n");
  339.     printf("    -tturn mins\t\tlimit each turn to <mins> minutes\n");
  340.     printf("    -w\t\t\tsuppress warnings\n");
  341.     printf("Long options:\n");
  342.     printf("    --help\t\t\tdisplay this help info\n");
  343.     printf("    --version\t\t\tdisplay version info\n");
  344.     game_usage_info();
  345.     printf("\nPlayer setup options:\n\n");
  346.     player_usage_info();
  347.     printf("\n");
  348. }
  349.  
  350. /* Describe the available variants for a game. */
  351.  
  352. void
  353. game_usage_info()
  354. {
  355.     int i;
  356.     char *varname = "?", *vartypename = NULL;
  357.     char buf[BUFSIZE];
  358.     Variant *var;
  359.  
  360.     printf("\nGame variant options");
  361.     if (mainmodule == NULL) {
  362.     printf(":\n\n    No game loaded, no information available.\n\n");
  363.     return;
  364.     }
  365.     printf(" for \"%s\":\n\n", mainmodule->name);
  366.     if (mainmodule->variants == NULL) {
  367.     printf("    No variants defined.\n\n");
  368.     return;
  369.     }
  370.     for (i = 0; mainmodule->variants[i].id != lispnil; ++i) {
  371.     var = &(mainmodule->variants[i]);
  372.     varname = var->name;
  373.     vartypename = c_string(var->id);
  374.     switch (keyword_code(vartypename)) {
  375.       case K_WORLD_SEEN:
  376.         printf("    -v\t\t\tmake the world be seen already (default %s)\n",
  377.            (var->dflt == lispnil ? "true" :
  378.             (c_number(eval(var->dflt)) ? "true" : "false")));
  379.         break;
  380.       case K_SEE_ALL:
  381.         printf("    -vv\t\t\tmake everything be always seen (default %s)\n",
  382.            (var->dflt == lispnil ? "true" :
  383.             (c_number(eval(var->dflt)) ? "true" : "false")));
  384.         break;
  385.       case K_SEQUENTIAL:
  386.         printf("    -vseq\t\t\tmove sequentially (default %s)\n",
  387.            (var->dflt == lispnil ? "true" :
  388.             (c_number(eval(var->dflt)) ? "true" : "false")));
  389.         break;
  390.       case K_WORLD_SIZE:
  391.         /* (is this accurate?) */
  392.         printf("    -M width[xheight][Wcircum][+lat][+lon]\tset world size (default ?)\n");
  393.         break;
  394.       default:
  395.         unixify_variant_name(buf, varname);
  396.         printf("    -v%s[=value] (default ", buf);
  397.         sprintlisp(buf, var->dflt);
  398.         printf(")\n");
  399.         break;
  400.     }
  401.     }
  402. }
  403.  
  404. /* Replace blanks in a variant's name with hyphens, and put the whole
  405.    name in lowercase. */
  406.  
  407. void
  408. unixify_variant_name(buf, varname)
  409. char *buf, *varname;
  410. {
  411.     int i, slen;
  412.  
  413.     strcpy(buf, varname);
  414.     slen = (int) strlen(buf);
  415.     for (i = 0; i < slen; ++i) {
  416.     if (buf[i] == ' ')
  417.       buf[i] = '-';
  418.     if (isupper(buf[i]))
  419.       buf[i] = tolower(buf[i]);
  420.     }
  421. }
  422.  
  423. void
  424. player_usage_info()
  425. {
  426.     printf("    name[,ai][/config][@host][+advantage]\tadd player\n");
  427.     printf("        ai\t\t= name of AI type\n");
  428.     printf("        config\t\t= name of config file\n");
  429.     printf("        host\t\t= name of player's host machine or display\n");
  430.     printf("        advantage\t= numerical initial advantage (default 1)\n");
  431.     printf("    -A\t\t\tuse AI with default player\n");
  432.     printf("    -e number[,ai]\tadd <number> computer players\n");
  433.     printf("    -h number[,ai]\tadd <number> human players\n");
  434.     printf("    -n\t\t\tno default player on local display\n");
  435.     printf("    -wait minutes\t\twait time for players to join\n");
  436. }
  437.  
  438. /* Given a string representing world dimensions, extract various components
  439.    and compose a variant setting. */
  440.  
  441. static void
  442. parse_world_option(str)
  443. char *str;
  444. {
  445.     int width, height, circumference = 0;
  446.     char *str2;
  447.  
  448.     width = atoi(str);
  449.     if ((str2 = strchr(str, 'x')) != NULL) {
  450.     height = atoi(str2 + 1);
  451.     } else {
  452.     height = width;
  453.     }
  454.     if ((str2 = strchr(str, 'W')) != NULL) {
  455.     circumference = atoi(str2 + 1);
  456.     } else {
  457.     /* (should get variant's default?) */
  458.     }
  459.     /* Glue onto the list of variant_settings. */
  460.     push_key_cdr_binding(&variant_settings, K_WORLD_SIZE,
  461.              cons(new_number(width),
  462.                   cons(new_number(height),
  463.                    cons(new_number(circumference),
  464.                     lispnil))));
  465. }
  466.  
  467. static void
  468. parse_realtime_option(subopt, arg)
  469. char *subopt, *arg;
  470. {
  471.     if (strcmp(subopt, "-timeout") == 0) {
  472.     option_alltimeout = 60 * atoi(arg);
  473.     } else if (strcmp(subopt, "-tgame") == 0) {
  474.     option_totalgametime = 60 * atoi(arg);
  475.     } else if (strcmp(subopt, "-tside") == 0) {
  476.     option_persidetime = 60 * atoi(arg);
  477.     } else if (strcmp(subopt, "-tturn") == 0) {
  478.     option_perturntime = 60 * atoi(arg);
  479.     } else {
  480.         /* usage? */
  481.     }
  482. }
  483.  
  484. /* Given a variant, turn it into a list "(name val)". */
  485.  
  486. static void
  487. parse_variant(str)
  488. char *str;
  489. {
  490.     char *varname = NULL, *str2;
  491.     Obj *varval = lispnil;
  492.  
  493.     if (strcmp(str, "") == 0) {
  494.     push_key_int_binding(&variant_settings, K_WORLD_SEEN, 1);
  495.     } else if (strcmp(str, "v") == 0) {
  496.     push_key_int_binding(&variant_settings, K_SEE_ALL, 1);
  497.     } else if (strcmp(str, "all") == 0) {
  498.     push_key_int_binding(&variant_settings, K_SEE_ALL, 1);
  499.     } else if (strcmp(str, "seq") == 0) {
  500.     push_key_int_binding(&variant_settings, K_SEQUENTIAL, 1);
  501.     } else if (strcmp(str, "simul") == 0) {
  502.     push_key_int_binding(&variant_settings, K_SEQUENTIAL, 0);
  503.     } else {
  504.     str2 = strchr(str, '=');
  505.     if (str2 != NULL && str2 != str) {
  506.         /* (should interp val as string or number) */
  507.         varval = new_number(atoi(str2 + 1));
  508.         varname = copy_string(str);
  509.         varname[str2 - str] = '\0';
  510.     } else {
  511.         varname = str;
  512.         varval = new_number(1);
  513.     }
  514.     if (varname)
  515.       push_binding(&variant_settings, intern_symbol(varname), varval);
  516.     }
  517. }
  518.  
  519. /* Load all the game modules that were asked for on cmd line. */
  520.  
  521. void
  522. load_all_modules()
  523. {
  524.     struct module_spec *extra;
  525.  
  526.     if (mainmodule != NULL) {
  527.     load_game_module(mainmodule, TRUE);
  528.     for (extra = extra_modules; extra != NULL; extra = extra->next) {
  529.         load_game_module(extra->module, TRUE);
  530.     }
  531.     } else {
  532.     /* If we've got absolutely no files to load, the standard game is
  533.        the one to go for.  It will direct the remainder of random gen. */
  534.     load_default_game();
  535.     }
  536. }
  537.  
  538. /* Set module variants from command line options. */
  539.  
  540. void
  541. set_variants_from_options()
  542. {
  543.     do_module_variants(mainmodule, variant_settings);
  544. }
  545.  
  546. /* Set player characteristics from command-line options. */
  547.  
  548. void
  549. set_players_from_options()
  550. {
  551.     Player *player;
  552.     struct raw_spec *spec;
  553.  
  554.     /* Assume that if players exist already, then this is a restored
  555.        game, and don't allow the command line to mess with the restored
  556.        players.  This is not ideal, because it means there is no way
  557.        to edit the player list, perhaps because one of the players
  558.        wants to be displayed on a different screen. */
  559.     if (numplayers > 0)
  560.       return;
  561.     /* Add the default player. */
  562.     if (raw_player_specs == NULL || option_add_default_player) {
  563.     player = add_default_player();
  564.     if (option_automate_default_player)
  565.       player->aitypename = "mplayer";
  566.     parse_player_spec(player, raw_default_player_spec);
  567.     canonicalize_player(player);
  568.     }
  569.     /* Add the explicitly listed players. */
  570.     for (spec = raw_player_specs; spec != NULL; spec = spec->next) {
  571.     player = add_player();
  572.     parse_player_spec(player, spec->spec);
  573.     canonicalize_player(player);
  574.     }
  575. }
  576.  
  577. /* Parse the syntax "[username][,ai][/config][@display][+advantage]". */
  578.  
  579. void
  580. parse_player_spec(player, spec)
  581. Player *player;
  582. char *spec;
  583. {
  584.     int commapos, slashpos, atpos, pluspos;
  585.  
  586.     if (spec != NULL && strcmp(spec, "*") != 0) {
  587.     /* Extract (destructively) a trailing advantage specification. */
  588.     pluspos = iindex('+', spec);
  589.     if (pluspos >= 0) {
  590.         player->advantage = max(1, atoi(&(spec[pluspos + 1])));
  591.         spec[pluspos] = '\0';
  592.     }
  593.     /* Extract a displayname if given. */
  594.     atpos = iindex('@', spec);
  595.     if (atpos >= 0) {
  596.         player->displayname = copy_string(spec + atpos + 1);
  597.         spec[atpos] = '\0';
  598.     }
  599.     /* Extract a configuration name if given. */
  600.     slashpos = iindex('/', spec);
  601.     if (slashpos >= 0) {
  602.         player->configname = copy_string(spec + slashpos + 1);
  603.         spec[slashpos] = '\0';
  604.     }
  605.     /* Extract an AI type if given. */
  606.     commapos = iindex(',', spec);
  607.     if (commapos >= 0) {
  608.         player->aitypename = copy_string(spec + commapos + 1);
  609.         spec[commapos] = '\0';
  610.     }
  611.     /* Just a plain old string left. */
  612.     if (strlen(spec) > 0) {
  613.         if (atpos >= 0) {
  614.         /* Display given separately, so this is a name. */
  615.         player->name = copy_string(spec);
  616.         } else {
  617.         player->displayname = copy_string(spec);
  618.         }
  619.     }
  620.     }
  621.     canonicalize_player(player);
  622. }
  623.  
  624. /* This is not, strictly speaking, part of command line processing,
  625.    but command-line programs also have stdio usually. */
  626.  
  627. void
  628. print_instructions()
  629. {
  630.     Obj *instructions = mainmodule->instructions, *rest;
  631.  
  632.     printf("\n");
  633.     if (instructions != lispnil) {
  634.     if (stringp(instructions)) {
  635.         printf("%s\n", c_string(instructions));
  636.     } else if (consp(instructions)) {
  637.         for (rest = instructions; rest != lispnil; rest = cdr(rest)) {
  638.         if (stringp(car(rest))) {
  639.             printf("%s\n", c_string(car(rest)));
  640.         } else {
  641.             /* (should probably warn about this case too) */
  642.         }
  643.         }
  644.     } else {
  645.         run_warning("Instructions are of wrong type");
  646.     }
  647.     } else {
  648.     printf("(no instructions supplied)\n");
  649.     }
  650. }
  651.